import java.util.*;
import java.io.*;

import graph.*;

public class GraphIndependenceTest {
    
    /* 
       This test creates two graphs using the same lists of 
       vertices and edges.  The resulting graphs should be
       independent of each other.  In other words, you should
       be able to change one without noticing any change to
       the other.
       
       My output for this test is at the bottom.
       
       */
       

    public static void main(String[] args) {
    
        Set<Vertex> vertices = new HashSet<Vertex>();
        Set<Edge> edges = new HashSet<Edge>();
        
        Set<Vertex> vertices2 = new HashSet<Vertex>();
        Set<Edge> edges2 = new HashSet<Edge>();
        
        Vertex aVert = new Vertex("A");
        Vertex bVert = new Vertex("B");
        Vertex cVert = new Vertex("C");              
        
        vertices.add(aVert);
        vertices.add(bVert);
        vertices.add(cVert);
        
        vertices2.add(aVert);
        vertices2.add(bVert);
        vertices2.add(cVert);
        
        edges2.add(new Edge(aVert,bVert,20));
        edges2.add(new Edge(bVert,cVert,30));
        
        edges.add(new Edge(aVert,bVert,20));
        edges.add(new Edge(bVert,cVert,30));
      
        /* We now create two different graphs, but using
           the same vertex and edge sets.
           This should result in two independent graphs.
           I should be able to change one without seeing 
           any change in the other and vice versa.  
         */ 
                 
        Graph g1 = new Graph(vertices,edges);
        Graph g2 = new Graph(vertices2,edges2);
        
        System.out.println("G1 Graph");
        System.out.println(g1);
        System.out.println();
        //System.out.println(g1.isConnected());
        
        System.out.println("G2 Graph");        
        System.out.println(g2);
        System.out.println();      
        
        Set<Edge> g1Edges = g1.getEdges();
        g1.removeEdge(g1Edges.iterator().next());  // take the first edge out of g1
        
        g2.addEdge( new Edge( g2.getVertex("C"), g2.getVertex("A"), 40));
        

        System.out.println("G1 Graph - after removing an edge");
        System.out.println("It should have one edge.  Does it?");
        System.out.println(g1);
        System.out.println(g1.isConnected());    
        
        
        System.out.println("G2 Graph - after adding an edge"); 
        System.out.println("It should have three edges.  Does it?");         
        System.out.println(g2);
        System.out.println(g2.isConnected());    
        
        
        
        
           
    }
    
    

}


////////////////////////////////////////////////////////////////////
//////////  OUTPUT WHEN I RUN THIS TEST ////////////////////////////
////////////////////////////////////////////////////////////////////

/*

 ----jGRASP exec: java GraphIndependenceTest

G1 Graph
Graph
Vertices: B A C 
Edges
B C 30.0
A B 20.0


G2 Graph
Graph
Vertices: B C A 
Edges
A B 20.0
B C 30.0


G1 Graph - after removing an edge
It should have one edge.  Does it?
Graph
Vertices: B A C 
Edges
A B 20.0


G2 Graph - after adding an edge
It should have three edges.  Does it?
Graph
Vertices: B C A 
Edges
C A 40.0
A B 20.0
B C 30.0



 ----jGRASP: operation complete.


*/